package cn.aitstone.service.service.impl;

import cn.aitstone.basic.exception.BusinessException;
import cn.aitstone.order.domain.OrderPetAcquisition;
import cn.aitstone.pet.domain.Pet;
import cn.aitstone.pet.domain.SearchMasterMsg;
import cn.aitstone.service.domain.UserProduct;
import cn.aitstone.service.dto.HandleProductDto;
import cn.aitstone.service.service.IUserProductService;
import cn.aitstone.basic.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Sheldon
 * @since 2022-07-21
 */
@Service
public class UserProductServiceImpl extends BaseServiceImpl<UserProduct> implements IUserProductService {

    @Override
    public void accept(HandleProductDto handleProductDto) {
//        /* 参数校验 */
//        if (StringUtils.isEmpty(handleProductDto.getHandler()) || StringUtils.isEmpty(handleProductDto.getNote())){
//            throw new BusinessException("参数不能为空");
//        }
//        // 查询此订单是否已经被接了，以及是否是取消的订单
//        OrderPetAcquisition orderPetAcquisition = orderPetAcquisitionMapper.loadByMsgIdAndNotCanceled(handleMsgDto.getMsgId());
//
//        if (orderPetAcquisition != null){
//            throw new BusinessException("此寻主消息已经被接单了");
//        }
//        // 根据寻主消息的主键id找到寻主消息对象
//        SearchMasterMsg searchMasterMsg = searchMasterMsgMapper.loadById(handleMsgDto.getMsgId());
//        Pet pet = msg2Pet(searchMasterMsg);
//        petMapper.save(pet);
//
//
//        orderPetAcquisition = initOrderPetAcquisition(handleMsgDto, searchMasterMsg, pet);
//
//        orderPetAcquisitionMapper.save(orderPetAcquisition);
    }
}
